#include <bits/stdc++.h>
#define N 100001
using namespace std;
typedef long long ll;
int n, m, a, b;
ll c;
ll f[N];
ll val[N << 2], lazy[N << 2];

inline void push_up(int cur) {
	val[cur] = val[cur << 1] + val[cur << 1 | 1];
}

void build(int cur, int l, int r) {
	if (l == r) {
		val[cur] = f[l];
		return;
	}
	int ls = cur << 1, rs = cur << 1 | 1, mid = (l + r) >> 1;
	build(ls, l, mid);
	build(rs, mid + 1, r);
	push_up(cur);
}

inline void push_down(int cur, int l, int r) {
	register int mid = (l + r) >> 1, ls = cur << 1, rs = cur << 1 | 1;
	lazy[ls] += lazy[cur];
	val[ls] += lazy[cur] * (mid - l + 1);
	lazy[rs] += lazy[cur];
	val[rs] += lazy[cur] * (r - mid);
	lazy[cur] = 0;
}

void modify(int cur, int l, int r, int L, int R, ll mod) {
	if (L <= l && r <= R) {
		val[cur] += mod * (r - l + 1);
		lazy[cur] += mod;
		return;
	}
	push_down(cur, l, r);
	int mid = (l + r) >> 1;
	if (L <= mid)
		modify(cur << 1, l, mid, L, R, mod);
	if (R > mid)
		modify(cur << 1 | 1, mid + 1, r, L, R, mod);
	push_up(cur);
}

ll query(int cur, int l, int r, int L, int R) {
	ll res = 0;
	if (L <= l && r <= R)
		return val[cur];
	int mid = (l + r) >> 1;
	push_down(cur, l, r);
	if (L <= mid)
		res += query(cur << 1, l, mid, L, R);
	if (mid < R)
		res += query(cur << 1 | 1, mid + 1, r, L, R);
	return res;
}
int main() {
	// freopen("testdata.in", "r", stdin);
	// freopen("testdata.out", "w", stdout);
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &f[i]);
	}
	build(1, 1, n);
	int op;
	while (m--) {
		scanf("%d", &op);
		switch (op) {
		case 1: {
			scanf("%d %d %lld", &a, &b, &c);
			modify(1, 1, n, a, b, c);
			break;
		}
		case 2: {
			scanf("%d %d", &a, &b);
			printf("%lld\n", query(1, 1, n, a, b));
			break;
		}
		}
	}
	// fclose(stdin);
	// fclose(stdout);
	return 0;
}